﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using XStudio.XCRF.Resources.Items;

namespace XStudio.XCRF.Web.Models.Items
{
    public class TNMInfo
    {
        private static IEnumerable<SelectListItem> _SelectListItems_T;
        public static IEnumerable<SelectListItem> SelectListItems_T
        {
            get
            {
                if (_SelectListItems_T == null)
                {
                    string[] Ts = { "TX", "T0", "Tis", "T1", "T2", "T3", "T4" };
                    _SelectListItems_T = GetSelectListItems(Ts,1,-1);
                }
                return _SelectListItems_T;
            }
        }
        private static IEnumerable<SelectListItem> _SelectListItems_N;
        public static IEnumerable<SelectListItem> SelectListItems_N
        {
            get
            {
                if (_SelectListItems_N == null)
                {
                    string[] Ns = { "NX", "N0", "N1", "N2" };
                    _SelectListItems_N = GetSelectListItems(Ns, 2, -1);
                }
                return _SelectListItems_N;
            }
        }
        private static IEnumerable<SelectListItem> _SelectListItems_M;
        public static IEnumerable<SelectListItem> SelectListItems_M
        {
            get
            {
                if (_SelectListItems_M == null)
                {
                    string[] Ms = { "MX", "M0", "M1" };
                    _SelectListItems_M = GetSelectListItems(Ms, 3, -1);
                }
                return _SelectListItems_M;
            }
        }

        private static IEnumerable<SelectListItem> GetSelectListItems(string[] keys,int flag ,int i)
        {
            Dictionary<String, String> TsAdvice = new Dictionary<string, string>();
            TsAdvice.Add("TX", "原发肿瘤无法估计");
            TsAdvice.Add("T0", "未发现原发肿瘤");
            TsAdvice.Add("Tis", "原位癌");
            TsAdvice.Add("T1", "肿瘤侵及黏膜下");
            TsAdvice.Add("T2", "肿瘤侵犯肌层");
            TsAdvice.Add("T3", "肿瘤穿透肌层至浆膜下或至无腹膜的结肠或直肠周围组织");
            TsAdvice.Add("T4", "肿瘤穿透脏器或(和)直接侵犯其它器官");

            Dictionary<String, String> NsAdvice = new Dictionary<string, string>();
            NsAdvice.Add("NX", "区域淋巴结情况不详");
            NsAdvice.Add("N0", "无区域淋巴结转移");
            NsAdvice.Add("N1", "1～3 个区域淋巴结转移");
            NsAdvice.Add("N2", "≥4 个区域淋巴结转移");

            Dictionary<String, String> MsAdvice = new Dictionary<string, string>();
            MsAdvice.Add("MX", "有无远处转移不详");
            MsAdvice.Add("M0", "无远处转移");
            MsAdvice.Add("M1", "有远处转移");

            Dictionary<String, String> texts = TsAdvice;
            if (flag == 2)
                texts = NsAdvice;
            else if (flag == 3)
                texts = MsAdvice;
            IEnumerable<SelectListItem> items = keys.Select(key =>
                    new SelectListItem
                    {
                        Text = TNMResource.ResourceManager.GetString(key) + texts[key],
                        Value = key
                    });
            return items;
        }
    }
}